<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
<head>
  <title>and_return (Spec::Mocks::BaseExpectation)</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <link rel="stylesheet" href="../../../.././rdoc-style.css" type="text/css" media="screen" />
</head>
<body class="standalone-code">
  <pre><span class="ruby-comment cmt"># File vendor\plugins\rspec/lib/spec/mocks/message_expectation.rb, line 30</span>
      <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">and_return</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">values</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">return_block</span>)
        <span class="ruby-constant">Kernel</span><span class="ruby-operator">::</span><span class="ruby-identifier">raise</span> <span class="ruby-constant">AmbiguousReturnError</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@method_block</span>.<span class="ruby-identifier">nil?</span>
        <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">values</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span>
          <span class="ruby-identifier">value</span> = <span class="ruby-keyword kw">nil</span>
        <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">values</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">==</span> <span class="ruby-value">1</span>
          <span class="ruby-identifier">value</span> = <span class="ruby-identifier">values</span>[<span class="ruby-value">0</span>]
        <span class="ruby-keyword kw">else</span>
          <span class="ruby-identifier">value</span> = <span class="ruby-identifier">values</span>
          <span class="ruby-ivar">@consecutive</span> = <span class="ruby-keyword kw">true</span>
          <span class="ruby-ivar">@expected_received_count</span> = <span class="ruby-identifier">values</span>.<span class="ruby-identifier">size</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@expected_received_count</span> <span class="ruby-operator">!=</span> <span class="ruby-identifier">:any</span> <span class="ruby-operator">&amp;&amp;</span>
                                                    <span class="ruby-ivar">@expected_received_count</span> <span class="ruby-operator">&lt;</span> <span class="ruby-identifier">values</span>.<span class="ruby-identifier">size</span>
        <span class="ruby-keyword kw">end</span>
        <span class="ruby-ivar">@return_block</span> = <span class="ruby-identifier">block_given?</span> <span class="ruby-value">? </span><span class="ruby-identifier">return_block</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">lambda</span> { <span class="ruby-identifier">value</span> }
      <span class="ruby-keyword kw">end</span></pre>
</body>
</html>